package com.bsj.media.media.gb28181;

/**
 * @Description 分辨率枚举工具
 * @Date 2022/8/9 17:04
 **/
public class RatioUtil {
    public static int getRatio(int width, int heigh) {
        int resolution = 0;
        if (width == 176 && heigh == 144) {
            // QCIF
            resolution = 0;
        } else if (width == 960 && heigh == 540) {
            // 普方达行车记录仪设备分辨率固定为这个
            resolution = 127;
        } else if (width == 1080 && heigh == 960) {
            // 当前960P
            resolution = 5;
        } else if (width == 1080 && heigh == 1920) {
            // 当前1080P
            resolution = 6;
        } else if (width == 288 && heigh == 352) {
            // 当前CIF
            resolution = 1;
        } else if (width >= 352 && width < 704 && heigh >= 288 && heigh < 576) {
            // CIF
            resolution = 1;
        } else if (width >= 704 && width < 1280 && heigh >= 288 && heigh < 576) {
            // 2CIF
            resolution = 2;
        } else if (width >= 704 && width < 1280 && heigh >= 576 && heigh < 720) {
            // 4CIF,D1
            resolution = 3;
        } else if (width >= 1280 && width < 1920 && heigh >= 720 && heigh < 960) {
            // 720P
            resolution = 4;
        } else if (width >= 1280 && width < 1920 && heigh >= 960 && heigh < 1080) {
            // 960P
            resolution = 5;
        } else if (width >= 1920 && width < 2560 && heigh >= 1080 && heigh < 1440) {
            // 1080P
            resolution = 6;
        } else if (width >= 2560 && heigh >= 1440) {
            // 2560x1440 2K
            resolution = 7;
        } else if (width >= 960 && width < 1280 && heigh >= 1080) {
            // 960*1080
            resolution = 20;
        } else {
            resolution = 1;
        }

        return resolution;
    }
}
